class ProcessDefinesController < ApplicationController
  before_action :set_process_define, only: [:show, :edit, :update, :destroy]

  # GET /process_defines
  # GET /process_defines.json
  def index
    @process_defines = initialize_grid(ProcessDefine.all, per_page:1)
  end

  def show1
    @process_define = ProcessDefine.find(1)
  end

  # GET /process_defines/1
  # GET /process_defines/1.json
  def show
  end

  # GET /process_defines/new
  def new
    @process_define = ProcessDefine.new
  end

  # GET /process_defines/1/edit
  def edit
  end

  # POST /process_defines
  # POST /process_defines.json
  def create
    @process_define = ProcessDefine.new(process_define_params)

    respond_to do |format|
      if @process_define.save
        format.html { redirect_to @process_define, notice: 'Process define was successfully created.' }
        format.json { render :show, status: :created, location: @process_define }
      else
        format.html { render :new }
        format.json { render json: @process_define.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /process_defines/1
  # PATCH/PUT /process_defines/1.json
  def update
    respond_to do |format|
      if @process_define.update(process_define_params)
        format.html { redirect_to @process_define, notice: 'Process define was successfully updated.' }
        format.json { render :show, status: :ok, location: @process_define }
      else
        format.html { render :edit }
        format.json { render json: @process_define.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /process_defines/1
  # DELETE /process_defines/1.json
  def destroy
    @process_define.destroy
    respond_to do |format|
      format.html { redirect_to process_defines_url, notice: 'Process define was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_process_define
      @process_define = ProcessDefine.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def process_define_params
      params.require(:process_define).permit(:bpmn_name, :current_version_code, :bpmn_id, :bpmn_key)
    end
end
